package com.block.datapush.service.filter;

import cn.hutool.core.util.StrUtil;
import com.block.datapush.model.param.FilterHandlerParam;
import com.block.datapush.model.result.FilterHandlerResult;
import com.block.datapush.service.IDataFilterItemService;
import com.block.db.entity.MemberSourceInfo;
import org.springframework.stereotype.Service;

@Service
public class FilterPushNumberHandlerService implements IDataFilterItemService {

    @Override
    public FilterHandlerResult handlerFilterLogic(FilterHandlerParam handlerParam, MemberSourceInfo memberSourceInfo) {

        Integer pushNumber = handlerParam.getPushNumber();
        Integer successNumber = handlerParam.getSuccessNumber();

        if (successNumber <= pushNumber){
            return FilterHandlerResult.success();
        }

        String message = StrUtil.format("【filter】{}【value】{}", pushNumber, successNumber);
        return FilterHandlerResult.error("PUSH_NUMBER_ERROR", message);
    }
}
